#pragma once
#include <vector>

enum ProcessEvents
{
	event_AddNew,
	event_DelProc
};

interface IProcessEvents
{
	virtual void OnProcessEvents(ProcessEvents eEvents,LPVOID postBuf,DWORD bufSize)=0;
};

struct ProcInfo
{
	DWORD pid;
	CHAR FilePath[MAX_PATH];
	BOOL isConnectNet;
	BYTE protocol;	//TCP UDP
	BOOL isAllow;
	DWORD FileCRC;
	BOOL isActive;
};

class CProcess
{
	static CRITICAL_SECTION m_cs;
	static IProcessEvents *m_IEvents;
	static HANDLE m_MonitorThreadHandle;
	static BOOL m_isMoning;
	static void PostBack(ProcessEvents eEvents,LPVOID postBuf,DWORD bufSize);
	static void Enter();
	static void Leave();

private:
	static std::vector<ProcInfo > m_ProcList;
	static BOOL IsProcessInList(LPSTR strFilePath);
	static BOOL IsProcessInList(DWORD pid,BOOL isNeedActive=TRUE);
	static DWORD WINAPI MonitorThread(LPVOID lpParameter);
	static void  UnActiveProcess();

	
public:
	static void Initialize();
	static void SetPostBack(IProcessEvents *IEvents);
	static void Release();
	static void StartMonitor();
	static void StopMonitor();
	static void RefreshProcessList();
	static BOOL GetProcInfo(int nID,ProcInfo &pi);
	static int	GetProcListCount();
	static void InjectDll(DWORD PID,LPSTR DllPath);
};
